package com.fifth.order.controller.api;

import com.fifth.common.pojo.entity.Order;
import com.fifth.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @作者：刘壬杉
 * @创建时间 2022/9/2 14:58
 **/
@Api(tags = "内部接口")
@RestController
@RequestMapping("api/order")
public class ApiOrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 根据code,goodsid查询订单信息
     * @param code
     * @param goodsid
     * @return
     */
    @ApiOperation("根据订单编号(code),商品id(goodsid)查询订单信息")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "String",name = "code",value = "订单编号"),
            @ApiImplicitParam(dataType = "String",name = "goodsid",value = "商品id")
    })
    @GetMapping("addcomment/{code}/{goodsid}")
    public Order addComment( @PathVariable String code,@PathVariable String goodsid){
        return orderService.addComment(code,goodsid);
    }

    /**
     * 根据goodsid获取商品的成交量
     * @param goodsid
     * @return
     */
    @ApiOperation("根据商品id获取商品的成交量")
    @ApiImplicitParam(dataType = "String",name = "goodsid",value = "商品id")
    @PostMapping("getGoodsSellNum/{goodsid}")
    public Integer getGoodsSellNum(@PathVariable String goodsid){
        return orderService.getGoodsSellNum(goodsid);
    }

    /**
     * 修改订单评论状态
     * @param goodsid
     * @param uid
     * @return
     */
    @PostMapping("updateOrderCommentStatus/{goodsid}/{uid}")
    public Integer updateOrderCommentStatus(@PathVariable String goodsid,@PathVariable String uid){
        return orderService.updateOrderCommentStatus(goodsid,uid);
    }

}
